package com.example.day01.controller;

import com.example.day01.pojo.User;
import com.example.day01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/save")
    public int SaveUser(){
        return -1;
    }
    @RequestMapping("/index")
    @ResponseBody
    public String findAll(Model model){
        List<User> users = userService.findAllUser();
        System.out.println(users);
        model.addAttribute("users",users);
        return "index";
    }

}
